<template>
	<!-- 此处改动， 文件为新添加组件 -->
	<view class="container" v-if="TanKuangHide">
		<!-- 弹框 -->
		<view class="tankaung" v-if="TanKuangHide">
			<view class="title">
				<image src="https://images.linglinggong.net/Frh-6iIMA4LDhT2LvE1yZisK5cV9" mode="" @click="close"></image>
				<view class="text">信息补充</view>
			</view>

			<!-- 备用联系人-->
			<view class="TEL" v-show="isTel">
				<view class="">备用联系人</view>
				<input type="number" value="" placeholder="请输入您的备用电话" maxlength="11" v-model="TelModel" />
			</view>

			<!-- 实名认证 -->
			<view class="Real-name" v-show="idCardNum" @click="Real_NName">
				<view class="tex1-name">实名认证</view>
				<view class="renzheng">
					<text :style="Real_name=='审核中' ? ' color:#1a1a1a':''">{{Real_name}}</text>
					<image src="https://images.linglinggong.net/icon1/finishInvite-jt.png" mode=""></image>
				</view>
			</view>

			<view class="" style="padding: 0 0  40rpx 0;" @click="OpenLLG">
				<view class="zlg-btn " :class=" bgcolor ? 'zlg-btn-bg':'' ">确定</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		putb64
	} from '@/libs/unit.js'
	export default {
		props:{
			RealName:{}
		},
		data() {
			return {
				order_listNumber :0,//订单数量
				bgcolor: false,
				TanKuangHide: false, //控制弹框隐藏
				Real_name: "去认证", //用户是否实名认证
				idCardNum: false, //根据身份证信息判断是否实名			进行隐藏
				isTel: false, //用户是否填写备用电话 			进行隐藏
				TelModel: "", //备用手机号
				idCardStatus: "",
				phonenumber: "", //注册的电话
			}
		},
		methods: {
			// 获取用户信息
			async getuserIfor() {
				let res = await this.$fetch(this.$api.get_current_user, {}, 'GET')
				// console.log(res.data.issuanceNum,"发单数量=============");
				console.log(res, "获取用户信息111")
				this.phonenumber = res.data.user.phonenumber //用户注册的电话
				if(res.data.issuanceNum<2){
					return
				}else if(res.data.issuanceNum>=2 && (res.data.idCardStatus == 0 || res.data.idCardStatus == 3)){
					this.idCardNum = true
					this.idCardStatus = res.data.idCardStatus
					this.TanKuangHide = true
				}else{
					// 判断是否实名 0: 待提交， 1：审核中， 2：审核通过， 3：审核驳回
					if (res.data.idCardStatus == 0 || res.data.idCardStatus == 3) {
						this.idCardNum = true
						this.idCardStatus = res.data.idCardStatus
						this.TanKuangHide = true
					}
					//是否填写备用电话
					if ( res.data.userType == 1 ) {
						if (res.data.standbytelephone == null) {
							this.isTel = true
							this.TanKuangHide = true
						}
					}
				}
				
					
			},
			// 获取手机
			phone(tel) {
				let res = this.$fetch(this.$api.updStandbytelephone, {
					telephone: tel
				}, "POST")
			},
			// 进入零工
			OpenLLG() {
				let reg = /^[1][3456789][0-9]{9}$/
				
				if (this.isTel == true ? !reg.test(this.TelModel) : false) {
					return uni.showToast({
						title: '手机号格式不正确',
						icon: 'none'
					})
				}
				if (this.TelModel == this.phonenumber) return uni.showToast({
					title: '备用手机号不能与注册电话相同',
					icon: 'none'
				})
				if ( this.Real_name == "审核中"? false : true) return uni.showToast({title: '请实名认证',icon: 'none'})
					
				if(this.Real_name == "审核中"){
						uni.showToast({title: '信息审核中，暂不能发布',icon: 'none'})
					
				}
				this.phone(this.TelModel)
				// 提交之后关闭弹框
				this.TanKuangHide = false
			},
			
			async order_list() {
				let res = await this.$fetch(this.$api.order_list,{pageSize:10},'POST')
				this.order_listNumber = res.rows.length
			},
			// 实名认证入口
			Real_NName() {
				uni.navigateTo({
					url: "/pages/real-name/real-name"
				})
			},
			// 关闭弹窗
			close() {
				this.TanKuangHide = false
			},
		},
		
		watch: {
			RealName:function(val){
				console.log(val.name);
				this.Real_name = val.name
			}
		},
		updated() {
			if ( this.TelModel != "" || this.idCardStatus!= "" || this.Real_name == '审核中') {
				this.bgcolor = true
			}
			//所有的选项都为false 控制弹框隐藏
			if (this.TouXiangHide == false && this.idCardNum == false && this.isTel ==false) {
				this.TanKuangHide = false
				// console.log("1111111");
			}
		},
		created() {
			this.order_list()
			// this.task_list()
			this.getuserIfor() //用户信息
			
		},
		
	}
</script>

<style scoped lang="less">
	.container {
		position: absolute;
		top: 0;
		width: 100vw;
		height: 100vh;
		background: rgba(0,0,0,.5);
		&>.tankaung {
			z-index: 999;
			width: 100vw;
			position: fixed;
			bottom: 0;
			// background: #F2F2F2;
			background-color: #F9F9F9;
			border-radius: 20rpx 20rpx 0 0 ;

			.title {
				width: 100vw;
				height: 108rpx;
				display: flex;
				align-items: center;
				// background-color: #FFFFFF;
				background: rgba(255, 255, 255, 0);

				image {
					width: 23rpx;
					height: 23rpx;
					margin: 0 251rpx 0 30rpx;
				}

				&>.text {
					height: 34rpx;
					font-size: 36rpx;
					font-weight: bold;
					color: #000000;
				}
			}

			
				

			
			&>.Real-name {
				width: 630rpx;
				padding: 0 30rpx;
				height: 88rpx;
				border-radius: 8rpx;
				margin: 0 auto 40rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				background: #FFFFFF;
				border-radius: 8rpx;

				.renzheng {
					.tex1-name {
						font-size: 32rpx;
						font-weight: 500;
						color: #000000;
					}

					color: #ABABAB;

					image {
						width: 28rpx;
						height: 28rpx;
						vertical-align: middle;
					}
				}

			}

			&>.TEL {
				width: 630rpx;
				height: 88rpx;
				margin: 0 auto 40rpx;
				background: #FFFFFF;
				border-radius: 8rpx;
				padding: 0 30rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				view {
					// width: 158rpx;
					// height: 31rpx;
					font-size: 32rpx;
					font-weight: 500;
					color: #000000;
				}

				input {
					width: 287rpx;
					height: 30rpx;
					font-size: 32rpx;
					font-weight: 500;
					text-align: right;
				}
			}

			.zlg-btn {
				margin: auto;
				width: 690rpx;
				height: 88rpx;

				border-radius: 12rpx;
				line-height: 88rpx;
				text-align: center;
				background: #ABABAB;
				color: #FFFFFF;
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: bold;
			}

			.zlg-btn-bg {
				background: #FCC928;
				color: #402110;
			}
		}
	}
</style>
